home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gnu / adainc / s-taspri.ads < prev    next >
Text File  |  1996-01-30  |  6KB  |  160 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                S Y S T E M . T A S K _ P R I M I T I V E S               --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.12 $                             --
  10. --                                                                          --
  11. --       Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved        --
  12. --                                                                          --
  13. -- GNARL is free software; you can redistribute it  and/or modify it  under --
  14. -- terms  of  the  GNU  Library General Public License  as published by the --
  15. -- Free Software  Foundation;  either version 2, or (at  your  option)  any --
  16. -- later  version.  GNARL is distributed  in the hope that  it will be use- --
  17. -- ful, but but WITHOUT ANY WARRANTY;  without even the implied warranty of --
  18. -- MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. -- eral Library Public License  for more details.  You should have received --
  20. -- a  copy of the GNU Library General Public License along with GNARL;  see --
  21. -- file COPYING.LIB.  If not,  write to the  Free Software Foundation,  675 --
  22. -- Mass Ave, Cambridge, MA 02139, USA.                                      --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with Interfaces.C;
  27. --  Used for Size_t;
  28.  
  29. with Interfaces.C.Pthreads;
  30. --  Used for, size_t,
  31. --            pthread_mutex_t,
  32. --            pthread_cond_t,
  33. --            pthread_t
  34.  
  35. with Interfaces.C.POSIX_RTE;
  36. --  Used for, Signal,
  37. --            siginfo_ptr,
  38.  
  39. with System.Task_Clock;
  40. --  Used for, Stimespec
  41.  
  42. with Unchecked_Conversion;
  43.  
  44. pragma Elaborate_All (Interfaces.C.Pthreads);
  45.  
  46. package System.Task_Primitives is
  47.  
  48.    --  Low level Task size and state definition
  49.  
  50.    type LL_Task_Procedure_Access is access procedure (Arg : System.Address);
  51.  
  52.    type Pre_Call_State is new System.Address;
  53.  
  54.    type Task_Storage_Size is new Interfaces.C.size_t;
  55.  
  56.    type Machine_Exceptions is new Interfaces.C.POSIX_RTE.Signal;
  57.  
  58.    type Error_Information is new Interfaces.C.POSIX_RTE.siginfo_ptr;
  59.  
  60.    type Lock is new Interfaces.C.Pthreads.pthread_mutex_t;
  61.    type Condition_Variable is new Interfaces.C.Pthreads.pthread_cond_t;
  62.  
  63. --  These definitions has to be private   ???
  64. --   type Lock is private;
  65. --   type Condition_Variable is private;
  66.  
  67.    --  The above types should both be limited.  They are not due to a hack in
  68.    --  ATCB allocation which allocates a block of the correct size and then
  69.    --  assigns an initalizized ATCB to it. This won't work with limited types.
  70.    --  When allocation is done with new, these can become limited once again.
  71.    --  ???
  72.  
  73.    type Task_Control_Block is record
  74.       LL_Entry_Point : LL_Task_Procedure_Access;
  75.       LL_Arg         : System.Address;
  76.       Thread         : Interfaces.C.Pthreads.pthread_t;
  77.       Stack_Size     : Task_Storage_Size;
  78.       Stack_Limit    : System.Address;
  79.    end record;
  80.  
  81.    type TCB_Ptr is access Task_Control_Block;
  82.  
  83.    --  Task ATCB related and variables.
  84.  
  85.    function Address_To_TCB_Ptr is new
  86.      Unchecked_Conversion (System.Address, TCB_Ptr);
  87.  
  88.    procedure Initialize_LL_Tasks (T : TCB_Ptr);
  89.  
  90.    function Self return TCB_Ptr;
  91.  
  92.    procedure Initialize_Lock (Prio : System.Priority; L : in out Lock);
  93.  
  94.    procedure Finalize_Lock (L : in out Lock);
  95.  
  96.    procedure Write_Lock (L : in out Lock; Ceiling_Violation : out Boolean);
  97.  
  98.    procedure Read_Lock (L : in out Lock; Ceiling_Violation : out Boolean);
  99.  
  100.    procedure Unlock (L : in out Lock);
  101.  
  102.    procedure Initialize_Cond (Cond : in out Condition_Variable);
  103.  
  104.    procedure Finalize_Cond (Cond : in out Condition_Variable);
  105.  
  106.    procedure Cond_Wait (Cond : in out Condition_Variable; L : in out Lock);
  107.  
  108.    procedure Cond_Timed_Wait
  109.      (Cond      : in out Condition_Variable;
  110.       L         : in out Lock; Abs_Time : Task_Clock.Stimespec;
  111.       Timed_Out : out Boolean);
  112.  
  113.    procedure Cond_Signal (Cond : in out Condition_Variable);
  114.  
  115.    procedure Cond_Broadcast (Cond : in out Condition_Variable);
  116.  
  117.    procedure Set_Priority (T : TCB_Ptr; Prio : System.Priority);
  118.  
  119.    procedure Set_Own_Priority (Prio : System.Priority);
  120.  
  121.    function Get_Priority (T : TCB_Ptr) return System.Priority;
  122.  
  123.    function Get_Own_Priority return System.Priority;
  124.  
  125.    procedure Create_LL_Task
  126.      (Priority       : System.Priority;
  127.       Stack_Size     :  Task_Storage_Size;
  128.       LL_Entry_Point : LL_Task_Procedure_Access;
  129.       Arg            : System.Address;
  130.       T              : TCB_Ptr);
  131.  
  132.    procedure Exit_LL_Task;
  133.  
  134.    procedure Abort_Task (T : TCB_Ptr);
  135.  
  136.    procedure Test_Abort;
  137.  
  138.    type Abort_Handler_Pointer is access procedure (Context : Pre_Call_State);
  139.  
  140.    procedure Install_Abort_Handler (Handler : Abort_Handler_Pointer);
  141.  
  142.    procedure Install_Error_Handler (Handler : System.Address);
  143.  
  144.    procedure LL_Assert (B : Boolean; M : String);
  145.  
  146.    Task_Wrapper_Frame : constant Integer := 72;
  147.    --  This is the size of the frame for the Pthread_Wrapper procedure.
  148.  
  149.    type Proc is access procedure (Addr : System.Address);
  150.  
  151.    procedure Test_And_Set (Flag_Add : System.Address; Result : out Boolean);
  152.    --  Flag_Add is the address of  a variable of type Boolean
  153.  
  154. --  private
  155.  
  156. --  type Lock is new Pthreads.pthread_mutex_t;                     ???
  157. --  type Condition_Variable is new Pthreads.pthread_cond_t;        ???
  158.  
  159. end System.Task_Primitives;
  160.